<template>
  <div class="app-container">
    <div style="text-align: center;margin-bottom: 30px">
      版本详情
    </div>
    <el-row :gutter="10">
      <el-form :model="appForm" ref="appForm" label-width="110px" class="form app_form">
        <el-form-item label="应用唯一号" prop="appKey">
          {{appForm.appKey}}
        </el-form-item>
        <el-form-item label="版本名" prop="versionName">
          {{appForm.versionName}}
        </el-form-item>
        <el-form-item label="版本号" prop="versionCode">
          {{appForm.versionCode}}
        </el-form-item>
        <el-form-item label="是否强制更新" prop="updateStatus">
          {{appForm.updateStatus}}
        </el-form-item>
        <el-form-item label="更新内容" prop="modifyContent">
          {{appForm.modifyContent}}
        </el-form-item>
        <el-form-item label="二维码">
          <div class="qrcode" ref="qrCodeUrl"></div>
        </el-form-item>
      </el-form>
    </el-row>


    <div slot="footer" style="text-align: center" class="dialog-footer">
      <el-button @click="cancelApk">取 消</el-button>
    </div>
  </div>
</template>

<script>
import QRCode from 'qrcodejs2'
import {
  getDataById
} from "@/api/apk";

export default {
  name: "apkEdit",
  components: {},
  data() {
    return {
      appForm: {
        appKey: "",
        appSize: 0,
        versionName: "",
        versionCode: "",
        modifyContent: "",
        updateStatus: 1,
      },
      addLoading: false
    }
  },
  created() {
    let ucId = this.$route.params.ucId
    this.getDataById(ucId)
  },
  methods: {
    getDataById(val) {
      getDataById({versionId: val}).then(res => {
        this.appForm = res.data.data
        this.creatQrCode()
      }).catch(res => {

      })
    },
    cancelApk() {
      window.history.back()
    },
    creatQrCode() {
      var qrcode = new QRCode(this.$refs.qrCodeUrl, {
        text: this.appForm.downloadUrl, // 需要转换为二维码的内容
        width: 100,
        height: 100,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      })
    }
  }
}
</script>

<style lang="less">
.qrcode {
  display: inline-block;
  img {
    width: 132px;
    height: 132px;
    background-color: #fff;
    padding: 6px;
    box-sizing: border-box;
  }
}
</style>
